/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */
struct TreeNode* p=NULL,*q=NULL;
void traverse(struct TreeNode* root)
{
    if(root)
    {
        traverse(root->left);
        q->right=root;
        q=root;
        q->left=NULL;
        traverse(root->right);
    }
}
struct TreeNode* convertBiNode(struct TreeNode* root)
{
    p=q=(struct TreeNode*)malloc(sizeof(struct TreeNode));
    q->right=NULL;
    traverse(root);
    return p->right;
}